<template>
  <el-card>
    <el-form :inline="true">
      <el-form-item label="一级分类">
        <el-select v-model="store.c1Id" @change="handler" :disabled="scene == 0 ? false : true">
          <el-option v-for="c1 in store.c1Arr" :key="c1.id" :label="c1.name" :value="c1.id" />
        </el-select>
      </el-form-item>
      <el-form-item label="二级分类">
        <el-select v-model="store.c2Id" @change="handler1" :disabled="scene == 0 ? false : true">
          <el-option v-for="c2 in store.c2Arr" :key="c2.id" :label="c2.name" :value="c2.id" />
        </el-select>
      </el-form-item>
      <el-form-item label="三级分类">
        <el-select v-model="store.c3Id" :disabled="scene == 0 ? false : true">
          <el-option v-for="c3 in store.c3Arr" :key="c3.id" :label="c3.name" :value="c3.id" />
        </el-select>
      </el-form-item>
    </el-form>
  </el-card>
</template>

<script setup lang="ts">
import { onMounted } from 'vue';
// 引入分类相关的仓库
import useCategoryStore from '@/store/modules/category';
const store = useCategoryStore()
onMounted(() => {
  getC1();
});
// 一级分类数据
const getC1 = () => {
  store.getC1()
}

// 一级分类改变
const handler = () => {
  store.c2Id = ''
  store.c3Arr = []
  store.c3Id = ''
  store.getC2()
}
// 二级分类改变
const handler1 = () => {
  store.c3Id = ''
  store.getC3()
}

// const scene = ref(0)
defineProps(['scene'])
</script>

<style scoped></style>